package com.jackiechan.day13;

import java.util.*;

public class Test_List {
    public static void main(String[] args) {
        List list = new ArrayList();
        list.add(0);
        list.add(1);
        list.add(2);
        list.add(4);
        list.add(5);
        list.add(3);
        list.add(4);
        list.add(null);
        System.out.println(list);
        // 在指定索引位置插入指定元素
        list.add(3,3);
        System.out.println(list);
        // 是否包含
        System.out.println(list.contains(2));
        // 得到指定索引位置的元素
        System.out.println(list.get(4));
        // 得到指定元素的第一个索引
        System.out.println(list.indexOf(3));
        // 得到指定元素的最后一个索引
        System.out.println(list.lastIndexOf(3));
        // 是否为空列表
        System.out.println(list.isEmpty());
        // 得到列表的长度
        System.out.println(list.size());
        // 返回指定索引之间的元素组成的集合
        System.out.println(list.subList(1,5));
        // 移除指定索引位置的元素,并返回
        System.out.println(list.remove(5));
        // 返回一个数组
        System.out.println(Arrays.toString(list.toArray()));

        List list1 = new ArrayList();
        for (int i=0;i<10;i++){
            list1.add(i*10);
        }
        System.out.println(list1);
        Iterator it = list1.listIterator();
        while (it.hasNext()){
            System.out.print(it.next()+" ");
        }
        System.out.println();
        Iterator it2 = list1.listIterator(6);
        while (it2.hasNext()){
            System.out.print(it2.next()+" ");
        }
        System.out.println();

        for(Object i:list){
            System.out.print(i+" ");
        }
        System.out.println();

        System.out.println("***********");
        ListIterator lit = list1.listIterator(5);
        while (lit.hasPrevious()){
            System.out.print(lit.previous()+" ");
        }
        System.out.println();
        while (lit.hasNext()){
            System.out.print(lit.next()+" ");
        }
        System.out.println();




        Character[] c = {'a','b','c'};
        System.out.println(Arrays.toString(c));
        List<Character> list3 = new ArrayList(Arrays.asList(c));
        System.out.println(list3);
        List<Character> list4 = new ArrayList(Arrays.asList('a','b','c'));
        System.out.println(list4);





//        List<Character> list2 = Arrays.asList();
//        List list2 = new ArrayList(Arrays.asList(chars));
//        System.out.println(list2.size());
//        Iterator it349 = list2.listIterator();
//        System.out.println(it349);
//        while (it349.hasNext()){
//            String s132 = Arrays.toString(it349.next());
//            System.out.print(it349.next()+" ");
//        }
//        System.out.println();
//
//        System.out.println(list2.getClass());
    }
}
